<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $model app\models\SamplePositionElse */
/* @var $form yii\widgets\ActiveForm */
$this->title = ($model->isNewRecord ? '创建' : '更新').'提取RNA信息';
$type = ($type == 1) ? 'dna' : 'rna';
$create_url = (($alter == '') ? 'create-m' : 'create-'.$type).'?from='.$model->from_id;
$options = ($model->xna_volumn_left != '' && $model->xna_volumn_left != 0) ? ['disabled' => true] : [];
?>

<div class="sample-position-else-form myForm">

    <div class="alert alert-danger" id="error-msg"></div>
    
    <?php $form = ActiveForm::begin(['id' => 'XnaForm']); ?>

    <b>编号: 
    <?php if ($model->xna_id != "") : ?>
        <?= $model->xna_id ?></b>
    <?php else : ?>
        <?= $model->from_id.'-' ?></b><?= Html::input('text', 'order', '', ['style' => 'width:30px;']) ?>
    <?php endif ;?>
    <?php if (($model->xna_id != "") || ($model->xna_id != "" && $type == "rna")) : ?>
        &nbsp;
        <span>
            <?= Html::a('<span class="glyphicon glyphicon-pencil"></span>', '#', ['id' => 'changeBtn']) ?>
            <?= Html::a('放弃更改', '#', ['id' => 'cancelBtn']) ?>
        </span>
    <?php endif ;?>
    <br />

    <?= $form->field($model, 'xna_volumn')->textInput($options)->error(false) ?>

    <?php if ($alter != '') : ?>

    <?= $form->field($alter, 'use_num')->textInput(['maxlength' => true])->error(false) ?>

    <?= $form->field($alter, 'origin_density')->textInput()->error(false) ?>

    <?= $form->field($alter, 'use_time')->textInput(['class'=>'form-control laydate-icon date'])->error(false) ?><br />

    <?= $form->field($alter, 'use_name')->textArea(['maxlength' => true])->error(false) ?><br />

    <hr>

    <?php endif; ?>

    <?= $form->field($model, 'xna_fridge')->dropDownList(Yii::$app->params[$type.'_fridge'], $options)->error(false) ?>

    <?= $form->field($model, 'xna_density')->textInput($options)->error(false) ?><br />

    <?= $form->field($model, 'case')->textInput($options)->error(false) ?>

    <?= $form->field($model, 'case_a')->textInput($options)->error(false) ?>

    <?= $form->field($model, 'case_b')->textInput($options)->error(false) ?><br />

    <?= $form->field($model, 'xna_x')->textInput($options)->error(false) ?>

    <?= $form->field($model, 'xna_y')->textInput($options)->error(false) ?>

    <?= $form->field($model, 'xna_z')->textInput($options)->error(false) ?><br />

    <input type="hidden" id="origin_density" value="<?= $model->xna_density ?>">
    <input type="hidden" id="status" value="<?= ($model->isNewRecord || $alter != null) ? $create_url : 'update?id='.$model->pk_id.'&type=xna' ?>">
    <div class="form-group">
        <?= Html::Button($model->isNewRecord ? '保存' : '更新', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary', 'id' => 'submitButton']) ?>

        <?= Html::a('取消', '/sample/view-'.$type, ['class' => 'btn btn-success', 'id' => 'backBtn']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
